package leetcode.每日一题;

import org.junit.Test;

/**
 * @author ：zsy
 * @date ：Created 2022/11/17 9:57 PM
 * @description：
 */
public class 匹配子序列的单词数 {
    @Test
    public void test() {

    }

    class Solution {
        public int numMatchingSubseq(String s, String[] words) {
            int ans = 0;
            for (String word : words) {
                if (isSubsequence(word, s)) {
                    ans++;
                }
            }
            return ans;
        }
        
        public boolean isSubsequence(String s, String t) {
            int i = 0, j = 0;
            while (i < s.length() && j < t.length()) {
                if (s.charAt(i) == t.charAt(j)) {
                    i++;
                }
                j++;
            }
            return i == s.length();
        }
    }
}
